#include<iostream>
typedef long long ll;
using namespace std;
ll quick_mul(ll a, ll b, ll p)
{
	ll ret = 0;
	while (b)
	{
		if (b & 1) ret = (ret + a) % p;
		a = (a + a) % p;
		b >>= 1;
	}
	return ret;
}
int main()
{
	ll a, b, p;cin >> a >> b >> p;
	cout << quick_mul(a, b, p);
	return 0;
}